﻿#include "User.h"
#include "Department.h"
#include "IFactory.h"
#include "AccessFactory.h"

int main(int argc, char *argv[])
{
    shared_ptr<User> user = shared_ptr<User>(new User());
    shared_ptr<Department> dept = shared_ptr<Department>(new Department());

    shared_ptr<IFactory> factory = shared_ptr<AccessFactory>(new AccessFactory());

    auto iu = factory->createUser();  //此时已与具体的数据库访问解除了依赖
    iu->insertUser(user);
    iu->getUser(1);

    auto id = factory->createDepartment();  //此时已与具体的数据库访问解除了依赖
    id->insertDepartment(dept);
    id->getDepartment(1);

    return 0;
}
